SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vwlAlumnosPilquenDivisiones
AS
SELECT     dbo.tb_AlumnoDivision.idRelDivisionAlumno AS ID, dbo.tb_Alumnos.Apellidos AS ApellidoEducacion, 
                      SageNacional.dbo.Alumnos_Pilquen.[ Apellido ] AS ApellidoPilquen, dbo.tb_Alumnos.Nombres AS NombreEducacion, 
                      SageNacional.dbo.Alumnos_Pilquen.[ Nombre ] AS NombrePilquen, dbo.tb_Alumnos.Documento, dbo.tb_Divisionestemp.Mnemo, 
                      dbo.tb_AlumnoDivision.AnioLectivo, dbo.tb_Divisionestemp.CUISE
FROM         SageNacional.dbo.Alumnos_Pilquen INNER JOIN
                      dbo.tb_Alumnos ON SageNacional.dbo.Alumnos_Pilquen.NroDoc = dbo.tb_Alumnos.Documento LEFT OUTER JOIN
                      dbo.tb_AlumnoDivision ON dbo.tb_Alumnos.idAlumno = dbo.tb_AlumnoDivision.Alumno INNER JOIN
                      dbo.tb_Divisionestemp ON dbo.tb_AlumnoDivision.Division = dbo.tb_Divisionestemp.idDivision
GO
GRANT SELECT ON  [dbo].[vwlAlumnosPilquenDivisiones] TO [Alumnos]
GO
